ReadMe.txt file from Clp2Dlfi directory Author: Brad Tharalson, CIS 72030,3045 This file briefly describes using the ToDelphi.dpr project file to convert xBase style code to Delphi code. As usual, make backups before starting, however, the code is not supposed to change any existing files. Before running this program, see the DBFDIRS.TXT file, add/change the directories listed there to point to some of your test DBF directories, the field info will be loaded for all DBF's in these directories, the files are not changed in any way. My own file contains the following database directories in DBFDIRS.TXT: \accting\comdat \accting\jcdat \accting\ardat \accting\apdat \accting\gldat After loading the ToDelphi project, use "Build All" the first time. If you try to run it immediately, it will tell you it can't find BTprint.pas. This program has two options to it, one translates PRG files to PAS files, the other translates DBF database files to PAS code that can be included in your code. The "Options" menu of the "Translate xBase Code" form allows you to select which type you want to do. PRG to PAS Conversion --------------------- First Step: Convert xBase code to dBase for Windows Style, this code comes from a routine I wrote several months ago and can be found in the dBase for Windows (DBW) forum. Second Step: Convert DBW code to Delphi code. Select "Translate xBase Code" on main "File" menu choice. When it opens it starts in the directory where the install took place. It will show one PRG file (tf.prg), this is a test file, double-click on this to start processing, it is about 200 lines. When done, you will see a file TEST.PAS in the right list box with a star next to it. If you double-click on this item, the converted code will appear along with the intermediate DBW code after it. I have about one-hundred thousand lines of xBase code that I am converting to Delphi. xBase code below (Print Customer Name List): use cust set print on set device to printer line=0 do while .not. eof() @ line,0 say cust->name line=line+1 skip enddo set device to screen set print off The equivalent Delphi code using wPreview code and DBserver.pas is below: Uses DBFserver, CommonCode, LinePrinter; procedure CustLIst; var lpp:Lpr; { Lpr is in unit wPreview.pas } tdb:oDB: { from DBserver.pas unit in Clp2Dlfi directory } begin lpp:=Lpr.create; tdb:=nil; dbUse(tdb,'cust'); { open Cust.dbf } with lpp do begin SetDestination; StartDoc(for8x11,'Customer List'); while not tdb.eof do begin { have to use "lpp.writeln" because WriteLn is built-in to Delphi, and it takes precedence if no qualifier } lpp.writeln(tdb.s('cust')); end; StopDoc; end; dbClose(tdb); lpp.free; end; Steps in Converting xBase Code to Delphi ---------------------------------------- With: .prg Output: .pas, translated program source code .prv, private variables .pub, public variables .txt, DBW intermediate code, can be deleted Determine which routines are for user input and delete them (these will have to be re-done in Delphi). Find all 'read' lines and delete the input lines, the vars filled by these routines will have to be passed in by the Window that calls it. With .prv and .pub (if one) determine each type of variable by looking at code. With resulting Delphi file, find the following and correct as needed: Check 'xx $ yy' ==> pin(xx,yy) conversions for syntax errors. Search for "YY", fix for-loop syntax, note: loop var must be local Look for 'iif(' to 'iifi(', if params not integer, use iifs() or iifd() Check occurances of Date() -> xDate, to see if DateMath() needs to be used. Check for ascan(), convert to "for" loop. Check syntax on str(), S/B str(aa,bb,cc) or str2(aa,bb) Find "dbf." and substitute correct "oDB" var. Search for ZZ of dbClose(ZZ) lines, change 'ZZ' to oDB var. During compile: when using actual numbers in floating math or comparisons, must add leading zero (unless its just zero). jj:=ii*.035 ==> jj:=ii*0.035; if jj<.003 then ... ==> if jj<0.003 then ... Search for procs, determine param and var types. Enter list of vars and arrays from .prv into 'Private' section. Enter list of vars and arrays from .pub into 'Public' section. 'CloseAll' should be changed to a series of dbClose() commands. Find occurances of and delete: Select, SelectArea. Find occurances of 'Alias', and delete or change to 'dbf.Alias'. DBF to PAS Conversion --------------------- This routine creates two files, .int and .imp for each .dbf. .int is placed in the Interface section of your code. .imp is placed in the Implementation section of your code. See wEshippr.pas in the Samples directory for examples. Good Luck